package com.hmys.api.controller;

import com.hmys.api.model.WebHouseProjectType;
import com.hmys.api.model.WebMessageLocation;
import com.hmys.api.model.WebWorkLocation;
import com.hmys.api.response.Result;
import com.hmys.api.response.ResultCode;
import com.hmys.api.service.WebMessageLocationService;
import com.hmys.api.service.WebWorkLocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chen365 on 2018/03/27.
 */
@RestController
@Api(tags = "地点")
@RequestMapping(value = "/location")
public class WorkLocationController {
    @Autowired
    private WebWorkLocationService webWorkLocationService;

    @Autowired
    private WebMessageLocationService webMessageLocationService;


    @ApiOperation(value = "工作地点", notes = "工作地点", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = "/work/list")
    public Object work() {
        WebWorkLocation webWorkLocation = new WebWorkLocation();
        webWorkLocation.setStatus(true);
        List<WebWorkLocation> list = webWorkLocationService.selectByBean(webWorkLocation);
        if (list.size() > 0) {
            return new Result<>(ResultCode.SUCCESS, list);
        } else {
            return new Result<>(ResultCode.NOT_FOUND);
        }
    }

    @ApiOperation(value = "留言地点", notes = "留言地点", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = "/message/list")
    public Object message() {
        WebMessageLocation webMessageLocation = new WebMessageLocation();
        webMessageLocation.setStatus(true);
        List<WebMessageLocation> list = webMessageLocationService.selectByBean(webMessageLocation);
        if (list.size() > 0) {
            return new Result<>(ResultCode.SUCCESS, list);
        } else {
            return new Result<>(ResultCode.NOT_FOUND);
        }
    }
}
